package com.csx.governance.sample.gw.config;

import com.csx.governance.sample.gw.feign.ServiceProviderClient;
import feign.AsyncFeign;
import feign.Feign;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.reactive.function.client.WebClient;

/**
 * @author cuisongxu
 * @date 2023/4/3 9:59
 */
@Configuration
public class GwConfiguration {

    @LoadBalanced
    @Bean
    public RestTemplate restTemplate() {
        return new RestTemplate();
    }

    @LoadBalanced
    @Bean
    public WebClient.Builder builder() {
        return WebClient.builder();
    }

    @Bean
    public ServiceProviderClient create() {
        return AsyncFeign.builder()
//                .encoder(new feign.jackson.JacksonEncoder())
//                .decoder(new feign.jackson.JacksonDecoder())
                .target(ServiceProviderClient.class, "http://serviceA");
    }
}
